<template>
  <div>

    <el-card shadow="never">
      <h3># 我发布的
      </h3>
      <span style="font-size:12px;color:#cdcdcd;">一些我发布的动态</span>
    </el-card>
    <br>

    <br>

    <el-card class="wrap" shadow="never">
      <!-- 使用卡片组件 -->
      <list-item v-for="item in dataList" :key="item.id" :show-del="true" :data="item" />
      <div v-if="dataList.length == 0" class="help">
        暂时没有内容哦！
      </div>
    </el-card>
  </div>
</template>

<script>
import ListItem from '../components/ListItem.vue'
import * as postApi from '@/api/post'
import { getUser } from '@/utils/auth'
import moment from 'moment'
export default {
  name: '',
  components: { ListItem },
  data() {
    return {
      dataList: [],
      userId: ''
    }
  },

  computed: {
  },

  created() {
    this.userId = getUser() ? getUser().id : ''
    this.getData()
  },
  methods: {
    getData() {
      postApi.list().then(resp => {
        this.dataList = resp.data.filter(item => item.userId === this.userId)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
  .help{
    color: #aaa;
    font-size: 14px;
  }
</style>
